package com.polaris.live.dialog

import android.content.Context
import com.bumptech.glide.Glide
import com.lxj.xpopup.core.CenterPopupView
import com.polaris.live.R
import com.polaris.live.common.ext.setOnSingleClickListener
import com.polaris.live.databinding.DialogToolVipCardSureBinding
import com.polaris.live.resp.back_resp.UserBackpackConsumableResp
import com.polaris.live.utils.image.ImageUtils

/**
 * ToolSureVipCardDialog vip卡确认使用
 *
 * @author Created by 天晴 on 2024/11/15/016 19:40
 */
class ToolSureVipCardDialog(
    context: Context,
    val item: UserBackpackConsumableResp,
    private val mGive: (() -> Unit)? = null,
    private val mOK: (() -> Unit)? = null,
) : CenterPopupView(context) {

    override fun getImplLayoutId(): Int {
        return R.layout.dialog_tool_vip_card_sure
    }

    private lateinit var mBinding: DialogToolVipCardSureBinding

    override fun onCreate() {
        super.onCreate()
        mBinding = DialogToolVipCardSureBinding.bind(popupImplView)
        mBinding.tvQx.setOnSingleClickListener {
            dismiss()
            mGive?.invoke()
        }
        mBinding.tvConfirm.setOnSingleClickListener {
            dismiss()
            mOK?.invoke()
        }
        Glide.with(context)
            .load(ImageUtils.imgPath(item.displayUrl))
            .into(mBinding.ivImage)
        mBinding.tvName.text = item.name
        mBinding.tvDetail.text = item.description ?: ""
    }
}